<template>
  <el-dialog
    v-el-drag-dialog
    title="退瓶任务单详情"
    :visible.sync="visible"
    width="1024px"
    @close="reset"
  >
    <div class="container">
      <div class="detail">
        <h3>退瓶任务单明细</h3>
        <div class="item-box">
          <div v-for="(item,index) in detailDataList" :key="index" class="item">
            <el-descriptions size="medium" :column="1">
              <el-descriptions-item label="商品名称">{{ item.goodsName }}</el-descriptions-item>
              <el-descriptions-item label="数量">{{ item.goodsCount }}</el-descriptions-item>
              <el-descriptions-item label="押金单号">{{ item.depositCode }}</el-descriptions-item>
              <!-- <el-descriptions-item label="气瓶编号">{{ item.recCodeIDS }}</el-descriptions-item> -->
              <el-descriptions-item label="气瓶编号">{{ item.recChipIDS }}</el-descriptions-item>
            </el-descriptions>
          </div>
        </div>

      </div>
      <div class="circul">
        <h3>流转信息</h3>
        <circul v-if="visible" ref="circul" :trace-list="traceList" />
      </div>
    </div>
  </el-dialog>
</template>

<script>
  import { queryReturnBottleOrderDetail, queryReturnBottleOrderFlowInfo } from '@/api'
  import { parseTime } from '@/filters'
  import moment from 'dayjs'
  import Circul from './Circul'

  export default {
    name: 'detail',
    components: {
      Circul
    },
    filters: {
      parseTime
    },
    data() {
      return {
        visible: false,
        billCode: '',
        billType: '',
        detailDataList: [],
        traceList: []
      }
    },
    methods: {
      moment,
      async open(temp) {
        this.billCode = temp.billCode
        this.billType = temp.billType
        await this.getDetail(temp)
        await this.getFlowData(temp)
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
        })
      },
      async getDetail(temp) {
        const res = await queryReturnBottleOrderDetail({
          backCode: temp.backCode
        })
        if (res.data) {
          this.detailDataList = res.data
        }
      },
      async getFlowData() {
        const res = await queryReturnBottleOrderFlowInfo({
          billCode: this.billCode,
          billType: this.billType
        })
        this.traceList = res.data
      },
      reset() {
        this.detailDataList = []
        this.traceList = []
      }
    }
  }
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  height: 450px;
  .detail {
    width: 450px;
    padding-right: 20px;
    .item-box {
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 50%;
      }
    }
  }
  .circul {
    height: 100%;
    padding-left: 20px;
    overflow-y: auto;
    border-left: 1px solid #dcdfe6;
    flex: 1;
    /deep/ .el-card__body {
      padding: 8px 10px 18px 10px;
      h4 {
        margin-top: 10px !important;
        margin-bottom: 10px !important;
      }
    }
  }
}
.item {
  margin-bottom: 28px;
  .title {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    .title-icon {
      display: inline-block;
      width: 4px;
      height: 18px;
      margin-right: 6px;
      background: #01999f;
    }
    .title-text {
      font-family: Microsoft YaHei, Microsoft YaHei-Bold;
      font-size: 14px;
      font-weight: 700;
      color: #01999f;
    }
    .content {
      margin-bottom: 28px;
    }
  }
  &:last-child {
    margin-bottom: 0;
  }
}
</style>
